import 'package:flutter/material.dart';
import 'package:jicaimao_flutter/utils/sp_key.dart';
import 'package:jicaimao_flutter/utils/sp_utils.dart';
import 'package:jicaimao_flutter/utils/toast.dart';
import 'package:jicaimao_flutter/utils/utils.dart';

/// 转入
class CheckIn extends StatefulWidget {
  @override
  _CheckInState createState() => _CheckInState();
}

class _CheckInState extends State<CheckIn> {

  var boxAdress ;
  @override
  void initState() {
    super.initState();
    String tempAdress = SpUtils.getString(SpKey.KEY_BOX_ADRESS);
    print("key= ${tempAdress}");
    setState(() {
       boxAdress = tempAdress;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        appBar: AppBar(
          centerTitle: true,
          elevation: 0.0,
          title: Text('转入', style: new TextStyle(color: Colors.black)),
          backgroundColor: Colors.white,
          iconTheme: IconThemeData(
              color: Colors.black
          ),
        ),
        body: Container(
          margin: EdgeInsets.only(top: 2.0),
          child: Column(
            children: <Widget>[
              Container(
                color: Colors.white,
                height: 110.0,
                margin: EdgeInsets.only(top: 2.0),
                padding: EdgeInsets.fromLTRB(15.0, 0.0, 15.0, 0.0),
                child: Column(
                  children: <Widget>[
                    Container(
                      height: 40.0,
                      child: Row(
                        children: <Widget>[
                          Expanded(child:
                          new Text('宝箱地址',style: new TextStyle(
                            //                        fontWeight: FontWeight.bold,
                              fontSize: 18.0,
                              color: Color(0xFF333333))
                          ),flex: 1,),
                          new Text('')
                        ],
                      ),
                    ),
                    Container(
                      height: 50.0,
                      child: Text(null !=boxAdress ? boxAdress :'还未绑定' ),
                      alignment: Alignment.centerLeft,
                    ),
                    Divider(
                      color: Color(0xFFE4E4E4),
                      height: 1.0,
                    )
                  ],
                ),
              ),
              new Container(
                height: 40.0,
                width: 400.0,
                margin: EdgeInsets.all(20.0),
                child:  RaisedButton(onPressed: (){
                     Utils.copyToClipboard(boxAdress);
                     Toast.toast(context, '已复制');
                },
                  color: Color(0xFFB969FF),
                  child: Text('复制地址' ,style: TextStyle(
                      fontSize: 16.0,
                      fontWeight: FontWeight.bold
                  ),),
                  textColor: Colors.white,


                ),
              ),
              Container(
                padding: EdgeInsets.fromLTRB(15.0, 0.0, 15.0, 0.0),
                margin: EdgeInsets.only(top: 15.0),
                child: Row(
                  children: <Widget>[
                    Expanded(child: Divider(),flex: 1,),
                    Container(
                      margin: EdgeInsets.symmetric(horizontal: 6.0),
                      child: Text("转入说明",style: TextStyle(
                        color: Color(0xFF999999),
                        fontSize: 12.0
                      ),),
                    ),

                    Expanded(child: Divider(),flex: 1,),
                  ],
                ),

              ),

              Container(
                padding: EdgeInsets.fromLTRB(25.0, 10.0, 25.0, 10.0),
                child:  Text("1.打开BSC钱包，复制您的BSC钱包地址\n"
                    "2.在本平台绑定粘贴复制好的地址\n"
                    "3.绑定成功后，就可以由BSC钱包转入积分到本平台温馨提示：转入的积分不得低于5000",style: TextStyle(
                  color:  Color(0xFF999999),
                  fontSize: 12.0
                ),),
              ),


            ],
          ),
        ),
      ),
    );
  }
}
